<template>
  <div>
    <nav-bar class=".nav-bar">
      <div slot="left">
        <img src="~assets/img/common/back.svg" alt="zzz" @click="backPage"/>
      </div>
      <div slot="center" class="title">
        <div
          v-for="(item,index) in titles"
          :key="index" @click="titleClick(index)"
          :class="{active:index==currentIndex}"
        >{{item}}</div>
      </div>
    </nav-bar>
  </div>
</template>

<script>
import NavBar from "components/common/navbar/NavBar";
export default {
  name: "DeatilNavBar",
  data() {
    return {
      titles: ["商品", "参数", "评论", "推荐"],
      currentIndex: 0
    };
  },
  components: {
    NavBar
  },
  methods: {
    backPage(){
      this.$router.replace('/home')
    }
    ,
    titleClick(index){
      this.currentIndex=index
    }
  }
};
</script>

<style scoped lang="scss">
.nav-bar {
  background-color: var(--color-background);
  color: var(--color-text);
  img {
    vertical-align: middle; /* 图片居中 */
    margin-left: -10px;
  }
}
.title {
  display: flex;
  div {
    flex: 1;
    font-size: 0.9em;
    padding: 0 5px;
  }
}
.active {
  color: var(--color-high-text);
}
</style>